package com.google.bitcoin.store;

import com.google.bitcoin.core.Wallet;
import com.google.bitcoin.core.NetworkParameters;

import org.bitcoinj.wallet.Protos;

import java.util.Collection;
import java.util.Collections;

/**
 * Optional helper for WalletProtobufSerializer that allows
 * for serialization and deserialization of Wallet objects with extensions
 * and corrsponding extended Wallet classes.
 */
public class WalletExtensionSerializer
{

    public Wallet newWallet(NetworkParameters params)
    {
        return new Wallet(params);
    }

    public void readExtension(Wallet wallet, Protos.Extension extProto) {
        if (extProto.getMandatory()) {
            throw new IllegalArgumentException("Did not understand a mandatory extension in the wallet");
        }
    }

    /**
     * Get collection of extensions to add, should be overridden by any class
     * adding wallet extensions
     *
     */
    public Collection<Protos.Extension> getExtensionsToWrite(Wallet wallet) {
        return Collections.<Protos.Extension>emptyList();
    }
    
}
